package com.xiaobai.nacosgateway.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.concurrent.Future;

@Service
public class UserServiceHolder {
    @Lazy // 重点：这里必须使用@Lazy
    @Autowired
    private UserService userService;


    @Async // 重点：这里必须在异步线程中执行，执行结果返回Future
    public Future<ApiResponse<User>> getToken(String access_token) {
        return new AsyncResult<>(userService.getToken(access_token));
    }
}
